package com.bdzl.auth.dao;

import com.bdzl.pub.entity.sys.RoleDO;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 系统角色表
 * @author yangyicai
 * @email yangyicai@foxmail.com
 * @date 2021-03-23 13:59:22
 */
public interface RoleDao {

	RoleDO get(Integer roleId);

	RoleDO getByRoleCode(String roleCode);

	List<RoleDO> list(Map<String, Object> map);

	int count(Map<String, Object> map);

	int save(RoleDO role);

	int update(RoleDO role);

	int remove(Integer role_id);

	int batchRemove(Integer[] roleIds);
	/**
	 * @Description: TODO 根据用户名查询所拥有角色
	 * @param username 用户名
	 * @return: java.util.List<java.lang.String>
	 * @Author: Ming
	 * @Date: 2021/4/27 18:21
	 */
	@Select("select role_code from sys_role where role_id in (select role_id from sys_user_role where user_id = (select user_id from sys_user where user_lgname=#{value}))")
	List<String> getRoleByUserName(String username);
}
